<?php

use think\migration\Seeder;
use app\common\model\Banner;

class InitDefaultBanners extends Seeder
{
    /**
     * Run Method.
     *
     * Write your database seeder using this method.
     *
     * More information on writing seeders is available here:
     * http://docs.phinx.org/en/latest/seeding.html
     */
    public function run()
    {
        $lists = [
            'link' => [
                ['title' => '中国高职高专教育网', 'link_url' => 'https://www.simpleedu.com.cn/'],
                ['title' => '西普教育', 'link_url' => 'https://www.simpleedu.com.cn/'],
                ['title' => '西普学苑', 'link_url' => 'https://www.simpleedu.com.cn/'],
                ['title' => '西普智控', 'link_url' => 'https://www.simpleedu.com.cn/'],
                ['title' => 'U-SaaS开放实验云平台', 'link_url' => 'https://www.simpleedu.com.cn/'],
                ['title' => '实验吧', 'link_url' => 'https://www.simpleedu.com.cn/'],
            ],
        ];

        $BannerModel = new Banner();
        foreach ($lists as $type => $items) {
            $default_data = [
                'status' => 1,
                'type' => $type,
            ];
            foreach ($items as $idx => $item) {
                $data = array_merge($item, $default_data);
                $BannerModel->findOrCreate($data);
            }
        }
    }
}